"""
用户创建请求模式
================

定义用户创建相关的数据传输对象
"""

from typing import Optional
from pydantic import BaseModel, EmailStr, Field


class UserCreateRequest(BaseModel):
    """用户创建请求"""
    username: str = Field(..., min_length=3, max_length=50, description="用户名")
    email: EmailStr = Field(..., description="邮箱地址")
    password: str = Field(..., min_length=6, max_length=128, description="密码")
    
    # 用户资料信息（所有字段都在 users 表中）
    full_name: Optional[str] = Field(None, max_length=100, description="全名")
    phone: Optional[str] = Field(None, max_length=20, description="电话号码")
    
    class Config:
        json_schema_extra = {
            "example": {
                "username": "johndoe",
                "email": "john@example.com",
                "password": "securepassword123",
                "full_name": "John Doe",
                "phone": "+1234567890"
            }
        }


class UserCreateResponse(BaseModel):
    """用户创建响应"""
    id: str = Field(..., description="用户ID")
    username: str = Field(..., description="用户名")
    email: str = Field(..., description="邮箱地址")
    is_active: bool = Field(..., description="是否激活")
    created_at: str = Field(..., description="创建时间")
    
    # 资料信息（可选）
    full_name: Optional[str] = Field(None, description="全名")
    phone: Optional[str] = Field(None, description="电话")
    bio: Optional[str] = Field(None, description="个人简介")
    
    class Config:
        json_schema_extra = {
            "example": {
                "id": "550e8400-e29b-41d4-a716-446655440000",
                "username": "johndoe",
                "email": "john@example.com",
                "is_active": True,
                "created_at": "2024-01-01T00:00:00Z",
                "full_name": "John Doe",
                "phone": "+1234567890",
                "bio": "Software developer passionate about clean code"
            }
        }
